package com.bz.content.feign;

import com.bz.content.feign.fallback.CommonContentFeignClientFallbackFactory;
import com.bz.pojo.TbContent;
import com.bz.pojo.TbContentCategory;
import com.bz.utils.PageResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 命令规范: 服务名称 + FeignClient
 */
@FeignClient(value = "common-content",fallbackFactory = CommonContentFeignClientFallbackFactory.class)
public interface CommonContentFeignClient {

    //--------------------------- /service/content --------------------------
    /**
     * 根据分类查询内容
     * @param page
     * @param size
     * @param categoryId
     * @return
     */
    @GetMapping("/service/content/selectTbContentAllByCategoryId")
    PageResult selectTbContentAllByCategoryId(@RequestParam("page") Integer page, @RequestParam("size") Integer size, @RequestParam("categoryId") Long categoryId);

    /**
     * 根据分类添加内容
     * @param tbContent
     * @return
     */
    @PostMapping("/service/content/insertTbContent")
    Integer insertTbContent(@RequestBody TbContent tbContent);

    /**
     * 删除分类下的内容
     * @param id
     * @return
     */
    @GetMapping("/service/content/deleteContentByIds")
    Integer deleteContentByIds(@RequestParam("id") Long id);

    //--------------------------- /service/contentCategory --------------------------
    /**
     * 根据父节点ID查询子节点
     * @param parentId
     * @return
     */
    @GetMapping("/service/contentCategory/selectContentCategoryByParentId")
    List<TbContentCategory> selectContentCategoryByParentId(@RequestParam("parentId") Long parentId);

    /**
     * 添加内容分类
     * @param tbContentCategory
     * @return
     */
    @PostMapping("/service/contentCategory/insertContentCategory")
    Integer insertContentCategory(@RequestBody TbContentCategory tbContentCategory);

    /**
     * 删除内容分类
     * @param tbContentCategory
     * @return
     */
    @PostMapping("/service/contentCategory/deleteContentCategoryById")
    Integer deleteContentCategoryById(@RequestBody TbContentCategory tbContentCategory);

    /**
     * 修改内容分类名称
     * @param tbContentCategory
     * @return
     */
    @PostMapping("/service/contentCategory/updateContentCategory")
    Integer updateContentCategory(@RequestBody TbContentCategory tbContentCategory);
}
